﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WPFStudy.Data;

namespace WPFStudy.View
{
    /// <summary>
    /// BindingWindow.xaml 的交互逻辑
    /// </summary>
    public partial class BindingWindow : Window
    {
        public BindingWindow()
        {
            InitializeComponent();
            spBinding.DataContext = new ListBoxDataModel()
            {
                Name = "Red",
                ColorCode = "#FF0000",
                Description = "红色"
            };
        }

        private void sliderEvent_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            textBox1Event.Text = sliderEvent?.Value.ToString();
            textBox2Event.Text = sliderEvent?.Value.ToString();
        }

        private void textBox1Event_TextChanged(object sender, TextChangedEventArgs e)
        {
            if(double.TryParse(textBox1Event.Text,out double value))
            {
                sliderEvent.Value = value;
            }
        }
    }
}
